﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Snowdreamist.Collection.Tree
{
    public interface ITreeNodeNavigator<T> where T : ITreeNode<T>
    {
        /// <summary>
        /// Current node
        /// </summary>
        T Current { get; }

        /// <summary>
        /// Move down into current node
        /// </summary>
        /// <returns></returns>
        bool MoveDown();

        /// <summary>
        /// Move up from current node
        /// </summary>
        /// <returns></returns>
        bool MoveUp();

        /// <summary>
        /// Move to previous node
        /// </summary>
        /// <returns></returns>
        bool MovePrev();

        /// <summary>
        /// Move to next node
        /// </summary>
        /// <returns></returns>
        bool MoveNext();

        /// <summary>
        /// Move to a specify node
        /// </summary>
        /// <param name="treeNode"></param>
        /// <returns></returns>
        bool MoveTo(T treeNode);

        /// <summary>
        /// Append children to current node (insert at the tail by default)
        /// </summary>
        /// <param name="treeNode"></param>
        /// <returns></returns>
        T AppendChild(T treeNode);

        /// <summary>
        /// Append node after current node
        /// </summary>
        /// <param name="treeNode"></param>
        /// <returns></returns>
        T AppendAfter(T treeNode);

        /// <summary>
        /// Append node before current node
        /// </summary>
        /// <param name="treeNode"></param>
        /// <returns></returns>
        T AppendBefore(T treeNode);

        /// <summary>
        /// Append children to current node and move to the new node
        /// </summary>
        /// <param name="treeNode"></param>
        /// <returns></returns>
        T AppendChildAndMoveTo(T treeNode);

        /// <summary>
        /// Append node after current node and move to the new node
        /// </summary>
        /// <param name="treeNode"></param>
        /// <returns></returns>
        T AppendAfterAndMoveTo(T treeNode);

        /// <summary>
        /// Append node before current node and move to the new node
        /// </summary>
        /// <param name="treeNode"></param>
        /// <returns></returns>
        T AppendBeforeAndMoveTo(T treeNode);

        /// <summary>
        /// Deep first traverse
        /// 深度遍历
        /// </summary>
        /// <param name="mode"></param>
        /// <returns></returns>
        ITreeNodeDeepFirstTraverseIterator<T> DeepFirstTraverse(DeepFirstTraverseMode mode);

        /// <summary>
        /// Breath first traverse
        /// 广度遍历
        /// </summary>
        /// <returns></returns>
        ITreeNodeIterator<T> BreadFirstTraverse();
    }
}